<?php
class VodClient {
	// 配置信息，要根据实际环境进行修改
	static $configInfo = array (
			"xstoreHost" => "https://vod-api.xstore.ctyun.cn/xstore-vod",
			"accessKey" => "",
			"secretKey" => "" 
	);
	// 静态数据，不可修改
	static $httpMethod = "POST";
	
	// 通用的执行流程
	public static function execute($reqData, $path) {
		// 拼接要调用的restful服务url
		$url = self::$configInfo ["xstoreHost"] . $path;
		
		$urlPath = parse_url ( $url ) ["path"];
		
		$signature = new \Signature ();
		// 获取当前时间
		$zoneDateTime = $signature->getZoneDateTime ();
		// 设置签名参数
		$signParam = new \SignParam ( $urlPath, self::$configInfo ["accessKey"], self::$configInfo ["secretKey"], $zoneDateTime, self::$httpMethod, null );
		// 根据签名参数生成签名
		$sign = $signature->sign ( $signParam );
		
		// 调用restful服务
		$http = new \Http ();
		$headers = array ();
		$headers [] = "Date:" . $zoneDateTime;
		$headers [] = "signature:" . $sign;
		$headers [] = "Content-Type:application/json;charset=utf-8";
		$httpOptions = array (
				CURLOPT_HTTPHEADER => $headers 
		);
		$result = $http->doPost ( $url, $reqData, $httpOptions );
		return $result;
	}
}
?>
